<HTML>
<head>
<title>AngelScript: Documentation: The variable parameter type</title>
<LINK rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

<p>
<a href="../index.html">index</a>
</p>

<h1>Documentation: The variable parameter type</h1>

<p>
The application can register functions that take a reference to a variable
type, which means that the function can receive a reference to a variable of
any type. This is useful when making generic containers.
</p>

<p>When a function is registered with this special parameter type, the
function will receive both the reference and an extra argument with the type
id of the variable type.</p>

<pre class=border>
<font color=green>// An example usage with a native function</font>
engine->RegisterGlobalFunction("void func_c(?&amp;in)", asFUNCTION(func_c), asCALL_CDECL);

void func_c(void *ref, int typeId)
{
    // Do something with the reference

    // The type of the reference is determined through the type id
}

<font color=green>// An example usage with a generic function</font>
engine->RegisterGlobalFunction("void func_g(?&amp;in)", asFUNCTION(func_g), asCALL_GENERIC);

void func_g(asIScriptGeneric *gen)
{
    void *ref = gen->GetArgAddress(0);
    int typeId = gen->GetArgTypeId(0);

    func_c(ref, typeId);
}
</pre>

<p>
The variable type can also be used with <tt>out</tt> references, but not
with <tt>inout</tt> references. Currently it can only be used with global
functions, object constructors, and object methods. It cannot be used with
other behaviours and operators.
</p>

<p>The variable type is not available within scripts, so it can only be used
to register application functions.</p>



<p><a href="#">top</a></p>

</body></HTML>
